package com.yanq.liancar.activity;

import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.GridLayoutManager;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.animation.AnimationUtils;
import android.view.animation.LayoutAnimationController;
import android.widget.Button;
import android.widget.PopupWindow;
import android.widget.TextView;

import com.vondear.rxtool.RxActivityTool;
import com.yanq.liancar.R;
import com.yanq.liancar.activity.base.BaseToolbarActivity;
import com.yanq.liancar.util.CommonPopupWindow;
import com.yanq.liancar.util.Utils;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class SmallBAddSreviceActivity extends BaseToolbarActivity {
    @BindView(R.id.tv_addService)
    Button tvAddService;
    @BindView(R.id.tv_popupwindow)
    TextView tvPopupwindow;
    PopupWindow popupWindow;
    private String stringType;
    private int  intType;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_small_b_addsrevice);
        Utils.setStatusBar(this, true, false);
        ButterKnife.bind(this);
        mTvTitle.setText("添加服务");
        stringType="精致洗车";
        intType=1;
    }

    @OnClick({R.id.tv_addService, R.id.tv_popupwindow})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tv_addService:
                Bundle bundle=new Bundle();
                bundle.putString("stringType",stringType);
                bundle.putInt("intType",intType);
               // RxActivityTool.skipActivity(mContext, SmallBServiceDescriptionActivity.class,bundle);
                break;
            case R.id.tv_popupwindow:
                popupWindow();
                break;
        }
    }

    private void popupWindow() {
        WindowManager wm = (WindowManager) this
                .getSystemService(Context.WINDOW_SERVICE);
        popupWindow = new PopupWindow(this);
        popupWindow.setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
        popupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
        View view = View.inflate(this, R.layout.popup_down, null);
        popupWindow.setContentView(view);
        popupWindow.setBackgroundDrawable(new ColorDrawable(0x00f1f1f1));
        popupWindow.setOutsideTouchable(false);
        popupWindow.setFocusable(true);
        popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public void onDismiss() {
            }
        });
        final TextView tv_child1 = (TextView) view.findViewById(R.id.tv1);
                        tv_child1.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                stringType="精致洗车";
                                intType=1;
                                tvPopupwindow.setText(tv_child1.getText().toString());
                                popupWindow.dismiss();
                            }
                        });
                        final TextView tv_child2 = (TextView) view.findViewById(R.id.tv2);
                        tv_child2.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                stringType="标准洗车";
                                intType=2;
                                tvPopupwindow.setText(tv_child2.getText().toString());
                                popupWindow.dismiss();
                            }
                        });
                        final TextView tv_child3 = (TextView) view.findViewById(R.id.tv3);
                        tv_child3.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                stringType="美容养护";
                                intType=3;
                                tvPopupwindow.setText(tv_child3.getText().toString());
                                popupWindow.dismiss();
                            }
                        });
                        final TextView tv_child4 = (TextView) view.findViewById(R.id.tv4);
                        tv_child4.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                stringType="到店保养";
                                intType=4;
                                tvPopupwindow.setText(tv_child4.getText().toString());
                                popupWindow.dismiss();
                            }
                        });
                        final TextView tv_child5 = (TextView) view.findViewById(R.id.tv5);
                        tv_child5.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                stringType="钣金喷漆";
                                intType=5;
                                tvPopupwindow.setText(tv_child5.getText().toString());
                                popupWindow.dismiss();
                            }
                        });
                        final TextView tv_child6 = (TextView) view.findViewById(R.id.tv6);
                        tv_child6.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                stringType="代办服务";
                                intType=6;
                                tvPopupwindow.setText(tv_child6.getText().toString());
                                popupWindow.dismiss();
                            }
                        });
        popupWindow.showAsDropDown(tvPopupwindow);
    }


}
